package com.matrix.java.chap_18;

public class Ex18_11 {
    public static void main(String[] args) {
        System.out.println(sumDigits(123123));
    }

    public static int sumDigits(long n) {
        int result = 0;
        if (n != 0) {
            result = Math.toIntExact(n % 10 + sumDigits(n / 10));
        }
        return result;
    }
}
